import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.*;

import java.io.IOException;
import java.net.URLEncoder;

/**
 * @author 86187
 * @classname ServletC
 * @time 2024/4/1
 * @project javaweb_project
 */
@WebServlet("/C")
public class ServletC extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
        String value="张三";
        value= URLEncoder.encode(value,"uTF-8");
        System.out.println("存储数据："+value);
        Cookie cookie=new Cookie("username",value);
cookie.setMaxAge(5000);
resp.addCookie(cookie);
    }
}


